<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="../../assets/layui/css/layui.css" rel="stylesheet">
    <link href="../../assets/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
</head>
<body>
<div style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="fm">
        <input type="hidden" name="id">
        <div class="fitem">
            <div class="layui-form-item">
                <label class="layui-form-label">name:</label>
                <div class="layui-input-block">
                    <input name="name" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="fitem">
            <div class="layui-form-item">
                <label class="layui-form-label">nameEn:</label>
                <div class="layui-input-block">
                    <input name="nameEn" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="fitem">
            <div class="layui-form-item">
                <label class="layui-form-label">nameTw:</label>
                <div class="layui-input-block">
                    <input name="nameTw" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="fitem">
            <div class="layui-form-item">
                <label class="layui-form-label">接口uri:</label>
                <div class="layui-input-block">
                    <input name="uri" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="fitem">
            <div class="layui-form-item">
                <label class="layui-form-label">uri_id:</label>
                <div class="layui-input-block">
                    <input name="uriId" class="layui-input">
                </div>
            </div>
        </div>
        <div class="fitem">
            <div class="layui-form-item">
                <label class="layui-form-label">请求类型(GET/POST/PUT):</label>
                <div class="layui-input-block">
                    <input name="method" class="layui-input">
                </div>
            </div>
        </div>
        <div class="fitem">
            <div class="layui-form-item">
                <label class="layui-form-label">资源类型，0接口,1功能:</label>
                <div class="layui-input-block">
                    <input name="resType" class="layui-input">
                </div>
            </div>
        </div>
        <div class="fitem">
            <div class="layui-form-item">
                <label class="layui-form-label">status:</label>
                <div class="layui-input-block">
                    <select name="status" lay-filter="status" id="status">
                    </select>
                </div>
            </div>
        </div>
        <input type="hidden" name="ifDel">
<!--        <div class="fitem">-->
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">创建时间:</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input name="createTime" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="fitem">-->
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">修改时间:</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input name="modifyTime" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="fitem">-->
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">创建人:</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input name="createUser" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="fitem">-->
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">修改人:</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input name="modifyUser" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="reset" class="layui-btn layui-btn-primary"
                        style="height: 33px;line-height: 33px;float: right;">重置
                </button>
                <button class="layui-btn" lay-submit="" lay-filter="btnSubmit"
                        style="height: 33px;line-height: 33px;background-color: #627aad;float: right;margin-right: 10px;">
                    立即提交
                </button>
            </div>
        </div>
    </form>
</div>
<script src="../../assets/layui/layui.js"></script>
<script src="../../js/common.translate.js"></script>
<script src="../../js/layui/common.js"></script>
<script src="../../js/layui/comm.dict.js"></script>
<script>
    var transTypeCode = 'DflResourcePo';
    //定义支持国际化的属性
    var transFields = 'name';
    var $;
    layui.use(['form'], function () {
        var form = layui.form;
        $ = layui.$;
        var id = getQueryString('id');
        transFields=getQueryString('transFields');

        selectOptions(layui, dict_status, 'status');
        form.render('select');

        if (id) {
            $.get("/dflResource/view", {id: id}, function (data) {
                if (data.success) {
                    trans_loadSuccessId(data.data, transTypeCode);
                    form.val('fm', data.data);
                } else {
                    layer.msg(data.errorMsg);
                    layer.close(index);
                }
            });
        }
        form.on('submit(btnSubmit)', function (data) {
            let index = layer.load();
            var paramJson=data.field;
            $.post("/dflResource/save", paramJson, function (data) {
                if (data.success) {
                    console.log(paramJson);
                    console.log(data.data);
                    trans_saveLocalLanguage(data.data, paramJson, transFields);
                    layer.msg("更新成功", {icon: 6});
                    setTimeout(function () {
                        window.parent.location.reload();
                    }, 1000);
                } else {
                    layer.msg(data.errorMsg);
                }
                layer.close(index);
            })
            return false;
        });
    })
</script>
</body>
</html>